const express = require('express')
const router = express.Router()
const path = require('path')
const multer = require('multer')
const storage = multer.diskStorage({
  destination: function(req, file, cb) {
    cb(null, path.join(__dirname, '../uploads/'))
  },
  filename: function(req, file, cb) {
    cb(null, Date.now() + '-' + file.originalname)
  }
})
const upload = multer({ storage })

const resourcesApi = require('../controller/resources')

router.put('/resources', upload.array('assets'), resourcesApi.putResources)

router.get('/resources/teams/:teamId', resourcesApi.getResourcesList)

router.get('/resources/:id', resourcesApi.downloadResource)

router.delete('/resources/:id', resourcesApi.deleteResource)

module.exports = router
